package com.etc.library.controller;

import com.etc.library.pojo.Message;
import com.etc.library.service.MessageService;
import com.etc.library.util.ResultBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/message")
public class MessageController {

    @Autowired
    private MessageService messageService;

    @PostMapping("/send")
    public ResultBody send(List<Message> messages) {
        if (messageService.add(messages))
            return ResultBody.success();
        return ResultBody.error();
    }

}
